package org.leopard.rpc;

/**
 * @author IBM CHEN ZHI KAN
 * @create 2018/8/13
 */
public abstract class Producer {
 private String host;
 private String port;
 private String klassName;
 private String url;

  public Producer(String host, String port, String klassName) {
    this.host = host;
    this.port = port;
    this.klassName = klassName;
  }

  public String getUrl(){
    if(url==null||url.equals("")){
      String simpleName=klassName.substring(klassName.lastIndexOf(".")+1,klassName.length());
      this.url = String.format("%s:%s/%s", host, port, simpleName);
    }
    return url;
  }
  public String getHost() {
    return host;
  }

  public void setHost(String host) {
    this.host = host;
  }

  public String getPort() {
    return port;
  }

  public void setPort(String port) {
    this.port = port;
  }

  public String getKlassName() {
    return klassName;
  }

  public void setKlassName(String klassName) {
    this.klassName = klassName;
  }

  /**
   * 生产者发布服务
   * @return
   */
  public abstract boolean publish(ServiceCenter serviceCenter);
}
